
from datetime import datetime
import json
import time
from openpyxl import load_workbook
import requests
import os

import execelUtil.common.commonUtil as comutils
import execelUtil.common.commonConstants as cons
import execelUtil.checkData.checkPurProduceTransit as chput
from execelUtil.componentUtil.wirte_text import writeDate_to_file



def read_exe(filename,limit) :
    workbook = load_workbook(filename,data_only=True)
    filepath = os.path.abspath("../respdata/purfile.text")
    print(filepath)
    po_zip_list = {}
    # 选择工作表
    i = 0
    sheet = workbook.active
    for row in sheet.iter_rows(min_row=2, max_row=sheet.max_row, values_only=True):
        sku = row[1]
        print(sku)
        po_zip_list, resp_sku = chput.checkPurTrasitQtyWithSuplr(sku)
        if 0 < limit < i:
            break
        if(row[10])!=resp_sku["produc_transit"]:
            writeDate_to_file(filepath, json.dumps(resp_sku)+",\n", "a")
        i +=1;
        time.sleep(2)


filename = r"C:\Users\Administrator\Downloads\pur_20250515.xlsx"
read_exe(filename,-1)